#include "utils.h"

#define BOOST_TEST_MODULE BoardTest

#include <boost/test/unit_test.hpp>
using utils::Board;

BOOST_AUTO_TEST_CASE (default_ctor)
{
	Board b;
	BOOST_CHECK( b.size() == 0 );
	BOOST_CHECK( b.none() != b.any() );
}

BOOST_AUTO_TEST_CASE (test_128_at)
{
	Board b(128);
	BOOST_CHECK( b.size() == 128 );
	for (size_t i = 0; i<b.size(); ++i)
	{
		BOOST_CHECK(b.at(i) == b[i]);
		BOOST_CHECK(b.at(i) == false);
	}
}

BOOST_AUTO_TEST_CASE (test_128_setAt)
{
	Board b(128);
	BOOST_CHECK( b.size() == 128 );
	for (size_t i = 0; i<b.size(); ++i)
	{
		BOOST_CHECK(b[i] == false);
		b.setAt(i,true);
		BOOST_CHECK(b[i] == true);
		b.setAt(i,false);
		BOOST_CHECK(b[i] == false);
	}

	for (size_t i = 1; i<b.size()-1; ++i)
	{
		BOOST_CHECK(b[i] == false);
		b.setAt(i,true);
		BOOST_CHECK(b[i] == true);
		BOOST_CHECK(b[i-1] == false);
		BOOST_CHECK(b[i+1] == false);
		b.setAt(i,false);
		BOOST_CHECK(b[i] == false);
		BOOST_CHECK(b[i-1] == false);
		BOOST_CHECK(b[i+1] == false);
	}
}